package laboratorio1;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Conexion{

  ResultSet rs;
  Connection con;
  Statement stmt;

    public Connection getCon() {
        return con;
    }

    public void setCon(Connection con) {
        this.con = con;
    }

    public ResultSet getRs() {
        return rs;
    }

    public void setRs(ResultSet rs) {
        this.rs = rs;
    }

    public Statement getStmt() {
        return stmt;
    }

    public void setStmt(Statement stmt) {
        this.stmt = stmt;
    }

  
    public void ejecutarquery(String tira)
    {

    String driver = "org.postgresql.Driver";
    String connectString = "jdbc:postgresql://localhost:5432/dBequipoNicolas";
   
    String user = "postgres";
    String password = "123";
    try{
    Class.forName(driver);
    con = DriverManager.getConnection(connectString, user , password);
    stmt = con.createStatement();
    rs = stmt.executeQuery(tira);
    }
    catch ( Exception e ){
    System.out.println(e.getMessage());
    }
    
    }

    public void cerrarquery()
    {
        try {
            stmt.close();
            con.close();
        } catch (SQLException ex) {
            Logger.getLogger(Conexion.class.getName()).log(Level.SEVERE, null, ex);
        }

    }


}
